public class Son {
    private String name;
    private Family family;
    public Son(String name){
        this.name =name;
    }
    public void setFamily(Family family) {
        this.family = family;
    }
    public void playGame(double money){
        synchronized (this.family){
            double leftMoney = this.family.getAccount();
            System.out.println("son 消费前，家庭余额："+ leftMoney);
            if(leftMoney >= money){
                this.family.setAccount(leftMoney-money);
                System.out.println("son消费后，家庭余额：" + this.family.getAccount());
            }else{
                System.out.println("账户余额不足，son暂停消费+++++++");
            }
        }
    }
}
